package com.cn.yang.service.impl;

import com.cn.yang.dao.NewsDao;
import com.cn.yang.dao.ProductDao;
import com.cn.yang.dao.impl.NewsDaoImpl;
import com.cn.yang.dao.impl.ProductDaoImpl;
import com.cn.yang.model.news.NewsClassifyModel;
import com.cn.yang.model.news.NewsModel;
import com.cn.yang.service.NewsService;

import java.util.List;

public class NewsServiceImpl implements NewsService {
    //查询 新闻种类
    @Override
    public List<NewsClassifyModel> findClassify() {
        NewsDao newsDao = new NewsDaoImpl();
        return newsDao.findClassify();
    }
//添加新闻
    @Override
    public int addNews(NewsModel model) {
        NewsDao newsDao = new NewsDaoImpl();
        return newsDao.addNews(model);
    }
//查询新闻
    @Override
    public List<NewsModel> findNews(NewsModel newsModel) {
        NewsDao newsDao = new NewsDaoImpl();
        return newsDao.findNews(newsModel);
    }
//查询总条数
    @Override
    public int countNews() {
        NewsDao newsDao = new NewsDaoImpl();
        return newsDao.countNews();
    }
//查询一条 id ======
    @Override
    public NewsModel selectById(Integer id) {
        NewsDao newsDao = new NewsDaoImpl();
        return newsDao.selectById(id);
    }
// 更新数据
    @Override
    public int updateNews(NewsModel model) {
        NewsDao newsDao = new NewsDaoImpl();
        return newsDao.updateNews(model);
    }
//删除数据
    @Override
    public int deleteById(Integer id) {
        NewsDao newsDao = new NewsDaoImpl();
        return newsDao.deleteById(id);
    }
}
